package c.x.jy.admin.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import c.x.jy.dao.entity.FanEntity;
import c.x.jy.service.service.FanService;
import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.R;



/**
 * 大师粉丝表
 *
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-05-25 10:46:12
 */
@RestController
@RequestMapping("teacher/fan")
public class FanController extends AbstractController {
    @Autowired
    private FanService fanService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("teacher:fan:list")
    public R list(@RequestParam Map<String, Object> params){
      
        PageUtils page = fanService.queryPage(params);

        return R.put(page);
    }
    /**
     * 列表
     */
    @RequestMapping("/listforweb")
    @RequiresPermissions("teacher:fan:list")
    public R listforweb(@RequestParam Map<String, Object> params){
      
        PageUtils page = fanService.listforweb(params);

        return R.put(page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{fanId}")
    @RequiresPermissions("teacher:fan:info")
    public R info(@PathVariable("fanId") Integer fanId){
		FanEntity fan = fanService.getById(fanId);

        return R.put(fan);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("teacher:fan:save")
    public R save(@RequestBody FanEntity fan){
		fanService.save(fan);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("teacher:fan:update")
    public R update(@RequestBody FanEntity fan){
		fanService.updateById(fan);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value="/delete/{fanId}" ,method = RequestMethod.DELETE)
    @RequiresPermissions("teacher:fan:delete")
    public R delete(@PathVariable("fanId") Integer fanId){
		fanService.removeByIds(Arrays.asList(fanId));

        return R.ok();
    }

}

